The Accordion Pane Component > Using the Accordion Pane component > Creating an application with the Accordion Pane component

 

Creating an application with the Accordion Pane component

The following procedure describes how to create a simple accordion pane. In this procedure, you enter simple ActionScript code to that adds 3 sections to the accordion pane. For more complex examples, see Examples for the Accordion Pane component.

 
To create a simple application using the Accordion Pane component:

1

Open Macromedia Flash MX.

2

Open the Components panel (Window > Components).

3

Select Flash UI Components Set 5 from the Components panel menu.

4

Drag an instance of the Accordion Pane component onto the stage.

5

Set the instance name of the Accordion Pane to myAccordion_acp.

6

Add a new layer to the main timeline and name it actions.

7

Select the new layer and open the Actions panel (Window > Actions).

8

In the Actions panel add the following code:

//remove the preset sections
myAccordion_acp.removeAll();

//add three sections to the component
myAccordion_acp.addItem("Item 1");
myAccordion_acp.addItem("Item 2");
myAccordion_acp.addItem("Item 3");

//create a listener object to list for events from the component.
var listener = new Object();

//create the onSelect method which is called when a section is selected
listener.onSelect = function(acp, item)
{
	trace("Section Selected : " + item.label);
}


//add the listener to the tab
myAccordion_acp.addListener(listener);

9

Save, publish, and test the movie. There will be an accordion pane component with 3 sections. When you select a section, the label of the selected section will be traced to the output window.

You can view the code for this example in the accordion_simple_example.fla example file.